using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace CallerID.Helpers
{
    public class EnumHelpers
    {
        /// <summary>
        /// Combines horizontal and vertical string aligment (left,center,right) into content alignment (top left, top center, ...)
        /// </summary>
        public static ContentAlignment StringAlignmentToContentAlignment(StringAlignment horizontal, StringAlignment vertical)
        {
            switch(vertical) {
                case StringAlignment.Near:
                    switch(horizontal) {
                        case StringAlignment.Near: return ContentAlignment.TopLeft;
                        case StringAlignment.Center: return ContentAlignment.TopCenter;
                        case StringAlignment.Far: return ContentAlignment.TopRight;
                    }
                    break;
                case StringAlignment.Center:
                    switch(horizontal) {
                        case StringAlignment.Near: return ContentAlignment.MiddleLeft;
                        case StringAlignment.Center: return ContentAlignment.MiddleCenter;
                        case StringAlignment.Far: return ContentAlignment.MiddleRight;
                    }
                    break;
                case StringAlignment.Far:
                    switch(horizontal) {
                        case StringAlignment.Near: return ContentAlignment.BottomLeft;
                        case StringAlignment.Center: return ContentAlignment.BottomCenter;
                        case StringAlignment.Far: return ContentAlignment.BottomRight;
                    }
                    break;
            }
            return ContentAlignment.TopLeft;
        }

        /// <summary>
        /// Returns vertical or horizontal string alignment from content alignment
        /// if vertical is true it returns vertical string alignment, else returns horizontal string alignment
        /// </summary>
        public static StringAlignment ContentAlignmentToStringAlignment(ContentAlignment alignment, bool vertical)
        {
            if(vertical) {
                switch(alignment) {
                    case ContentAlignment.TopLeft:
                    case ContentAlignment.TopCenter:
                    case ContentAlignment.TopRight:
                        return StringAlignment.Near;
                    case ContentAlignment.MiddleLeft:
                    case ContentAlignment.MiddleCenter:
                    case ContentAlignment.MiddleRight:
                        return StringAlignment.Center;
                    case ContentAlignment.BottomLeft:
                    case ContentAlignment.BottomCenter:
                    case ContentAlignment.BottomRight:
                        return StringAlignment.Far;
                }
            } else {
                switch(alignment) {
                    case ContentAlignment.TopLeft:
                    case ContentAlignment.MiddleLeft:
                    case ContentAlignment.BottomLeft:
                        return StringAlignment.Near;
                    case ContentAlignment.TopCenter:
                    case ContentAlignment.MiddleCenter:
                    case ContentAlignment.BottomCenter:
                        return StringAlignment.Center;
                    case ContentAlignment.TopRight:
                    case ContentAlignment.MiddleRight:
                    case ContentAlignment.BottomRight:
                        return StringAlignment.Far;
                }
            }
            return StringAlignment.Near;
        }
    }
}
